import requests
import re

url = 'https://www.hdbz.net'

response = requests.get(url)
html = response.content.decode('utf-8')
results = re.findall(
    r'<a href="(/wallpaper/\d{6}/\d{6}\.html)" target="_blank" title="(.*?)".*?data-original="(.*?)" alt=".*?" class="lazy" />',
    html, re.S)
for result in results:
    suo_img_url = result[2]
    title = result[1]
    img_url = url + result[0]
    print(img_url)
    img_response = requests.get(img_url)
    img_html = img_response.content.decode('utf-8')
    img = re.findall(r'<div class="pic-preview">.*?<img alt=".*?" src="(.*?)" />.*?</div>', img_html, re.S)
    img_response = requests.get(img[0])
    with open(f'static/高清壁纸/{title}.png', 'wb') as f:
        f.write(img_response.content)
